<?php
namespace app\admin\validate;

use think\Validate;

class Article extends Validate
{
    protected $rule = [
        'title'  =>  'require|max:90|unique:article',
        'keywords'  =>  'require|max:100',
        'desc' =>  'require|max:150',
        "status" => 'require|in:0,1',
    ];
    
    protected $message  =   [
        'title.require' => '文章标题不能为空',
        'title.max'     => '文章标题最多不能超过90个字符',
        'title.unique'  => '文章标题不能重复',
        'keywords.require' => '文章关键词不能为空',
        'keywords.max'  => '文章关键词最多不能超过100个字符',
        'desc.require'  => '文章描述不能为空',
        'desc.max'      => '文章描述最多不能超过150个字符',
        'status.require' => '必须选择下拉框当中的文章发布状态',
        'status.in'     => "文章发布状态必须为'草稿'或'发布'",
    ];
    
    protected $scene = [
        'edit' => ['title' => 'require|max:90','keywords' => 'require|max:100','desc' =>  'require|max:150',"status" => 'require|in:0,1'],
    ];
}